//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.guideshow;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

public class FragmentTabAdapter extends FragmentPagerAdapter {
    private List<SinglePage> mGuideContent;
    private Context mCtx;

    public FragmentTabAdapter(FragmentActivity a, List<SinglePage> guideContent) {
        super(a.getSupportFragmentManager());
        this.mCtx = a;
        this.mGuideContent = guideContent;
    }

    public Fragment getItem(int position) {
        SinglePage sp = (SinglePage) this.mGuideContent.get(position);
        if (sp.mCustomFragment != null) {
            return sp.mCustomFragment;
        } else {
            FragmentTabAdapter.PageFragment pageFragment = (FragmentTabAdapter.PageFragment) Fragment.instantiate(this.mCtx, FragmentTabAdapter.PageFragment.class.getName());
            if (sp.mBackground != null) {
                pageFragment.setBg(sp.mBackground);
            }

            return pageFragment;
        }
    }

    public int getCount() {
        return this.mGuideContent.size();
    }

    public static final class PageFragment extends Fragment {
        private Drawable mBg;

        public PageFragment() {
        }

        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            ImageView iv = new ImageView(this.getActivity());
            if (this.mBg != null) {
                iv.setBackground(this.mBg);
            }

            return iv;
        }

        public void setBg(Drawable mBackground) {
            this.mBg = mBackground;
        }
    }
}
